<?php
/*
 * 主播验证
*/
namespace App\Validation;

use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Numericality;
use Phalcon\Validation\Validator\Regex;

class AgentValidation extends BaseValidation
{
    public function initialize()
    {
		
		$this->add(
			"name",
			new PresenceOf(
				  [
					  "message" => "The name is required",
				  ]
			)
		);
		
		$this->add(
			"identity_num",
			new PresenceOf(
				  [
					  "message" => "The identity_num is required",
				  ]
			)
		);		
		
		$this->add(
			"identity_num",
			new Regex(
				  [
					  "message" => "The identity_num a olute or self-relative",
					  "pattern"    => "/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/",
					  "allowEmpty" => true,
				  ]
			)
		);
		
		

		$this->add(
			"front_image",
			new PresenceOf(
				  [
					  "message" => "The front_image is required",
				  ]
			)
		);
		
		$this->add(
			"back_image",
			new PresenceOf(
				  [
					  "message" => "The back_image is required",
				  ]
			)
		);		
	
    }
	
	//验证之前
	public function beforeValidation($data, $entity, $messages)
    {
		
        return true;
    }
	
}